package com.dong.dao;

import com.dong.entity.Account;
import com.dong.entity.Orders;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("ordersDao")
public interface IOrdersDao {
    @Select("select * from orders where a_id=#{a_id}")
    public Orders findOrdersByaid(int id);

    @Select("select * from orders")
    @Results(value = {
            @Result(id = true,property = "o_id",column = "o_id"),
            @Result(property = "o_name",column = "o_name"),
            @Result(property = "o_date",column = "o_date"),
            @Result(property = "o_money",column = "o_money"),
//            @Result(property = "a_id",column = "a_id"),
            @Result(property = "account",column = "a_id",javaType = Account.class,
            one = @One(select = "com.dong.dao.IAccountDao.findById"))
    })
    public List<Orders> findAllOrders();
}
